package com.loopy.fruns.service.impl;

import com.loopy.fruns.dao.MemberDAO;
import com.loopy.fruns.dao.impl.MemberDAOImpl;
import com.loopy.fruns.entity.Member;
import com.loopy.fruns.service.MemberService;

public class MemberServiceImpl implements MemberService {
    private MemberDAO memberDAO=new MemberDAOImpl();
    /**
     * 注册用户
     * @param member
     * @return成功true，失败false
     */
    @Override
    public boolean registerMember(Member member) {
        int i = memberDAO.saveMember(member);
        return i==-1?false:true;

    }

    /**
     * 判断用户名是否存在
     * @param username
     * @return
     */
    @Override
    public boolean isExitsUserName(String username) {
        Member member = memberDAO.queryMemberByUserName(username);
        return member!=null?true:false;
    }

    @Override
    public Member login(Member member) {
        return memberDAO.queryMemberByUserNameAndPassword(member.getUsername(), member.getPassword());
    }
}
